#ifndef _ioconnections_h_
#define _ioconnections_h_

#include <string>
#include <boost/bind.hpp>
#include <boost/function.hpp>

using namespace std;

class Predictor_link;
class Model_link;
class Predictor_base;
class Machine;
class Model;
class Output_base;

class Connection
{
public:
  Connection();
  virtual ~Connection();

  void set_name(string name);
  string get_name(void);

  void set_id(int name);
  int get_id(void);

protected:
  string _name;
  int _id;
};

class IConnection: public Connection
{
public:
  IConnection(Predictor_link *_l);
  IConnection(Machine *m, Predictor_base *p, int iLink);

  virtual ~IConnection();

  void set_link(Predictor_link *_l);
  Predictor_link *get_link(void);

  void get_value(void);

  void set_value_p(float *p);
  float *get_value_p(void);

private:
  Predictor_link *_link;
  float *_value_p;
};

class OConnection: public Connection
{
public:
  OConnection(Machine *m, Model *p);
  OConnection(Model_link *l);
  virtual ~OConnection();

  void set_link(Model_link *l);
  Model_link *get_link(void);

  void set_value(void);
  void set_function(boost::function<void(float)> f);

  double get_output_value(void);

  Output_base *get_output(void);
  void set_output(Output_base *output);

  bool OConnection::is_active();

private:
  Model_link *_model_link;
  boost::function<void(float)> _out_function;
  Output_base *_output;

};

#endif
